import $ from "jquery";
import {url} from "../../util/config";
import {success} from "../../util/responseStatus";
import {message} from "antd";
import login from "../login";
function getNewLogin(values) {
    return sortNum(values)
}
export default function sortNum(values) {
    console.log("values",values)

    let token = localStorage.getItem("token")
    let status = null;

    if(values.sortNum=="" || values.sortNum==undefined || values.sortNum==null){
        status = "N"
    }else {
        $.ajax({
            async:false,
            headers: {
                'Accept': "application/json",
                'Authorization': token
            },
            url: url.api_url+`Module/SortNum?id=${values.id}&sortNum=${values.sortNum}`,
            type: 'GET',
            contentType:"application/json",
            success: function (result) {
                if(result.result=="Token過期請重新登錄"){
                    login(localStorage.getItem("account"), localStorage.getItem("password"));
                    status = getNewLogin(values)
                }else {
                    if(result.result=="Y"){
                        status = "Y"
                    }else if(result.result=="N"){
                        status = "N"
                    }
                }
            },
            error:function (error) {
                status = "error"
                message.error("请求异常")
            }
        })
    }
    return status;
}
